package com.zj.utils.utils

import android.app.Activity
import android.content.Context
import android.view.inputmethod.InputMethodManager
import jxl.write.WritableSheet

object Utils {

    /**
     * 隐藏软键盘
     */
    fun hideKeyboard(activity: Activity){
        val view = activity.window.peekDecorView()
        if (null != view){
            val inputManager: InputMethodManager = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
            inputManager.hideSoftInputFromWindow(view.windowToken, 0)
        }
    }

    /**
     * 合并指定列数的某几行单元格
     *
     * @param sheet WritableSheet Excel Sheet
     * @param colNum Int 需要合并多少列
     * @param startRaw Int 需要合并行的起始
     * @param endRaw Int 需要合并行的结束
     */
    fun mergeCells(sheet: WritableSheet, colNum: Int, startRaw: Int, endRaw: Int){
        for (i in 0 until colNum){
            sheet.mergeCells(i, startRaw, i, endRaw)
        }
    }
}